<?php

require_once ("./class/H.class.php");
require_once ("./class/database.class.php");

$retData = [];
$pData = $dbm->select("tb_region",['id','name'],['rid' => 0]);

foreach($pData as $k => $v){
    $tData = $dbm->select("tb_region",['id','name'],['rid' => $v['id'],'ctime[>]' => 0]);
    $retData[$k] = [
        'rid' => $v['id'],
        'name' => $v['name'],
        'children' => $tData
    ];
}
$retJson = H::json_encode_ch(['status'=>'ok','msg'=>'success','data'=>$retData]);
if (!empty($_GET['callback'])) {
    die($_GET['callback'] . '(' . $retJson . ')'); // jsonp
} else {
    die($retJson);
}






